<style lang="less" scoped>
    @import "../../less/_variable.less";
    @import "./css/specifications";

    .details_cont {
        //
        top: 0 !important;
        overflow-y: hidden;

        // 底部购买
        .footer_buy {
            position: absolute;
            background: #fff;
            bottom: 0;
            left: 0;
            right: 0;
            width: 100%;
            height: 1.12rem;
            display: flex;
            flex-direction: row;
            flex-wrap: nowrap;
            &.share {
                .along, .group {
                    flex: 1;
                }
            }

            .goback {
                width: 14.67%;

                a {
                    display: block;
                    margin: 0 auto;
                    width: 1.1rem;
                    height: 100%;
                    text-align: center;

                    .find {
                        width: 0.66rem;
                        height: 0.5rem;
                        margin: 0.18rem 0.26rem 0.12rem;
                        background: url(../../assets/img/find.png) no-repeat center 0;
                        background-size: 100% 100%;
                    }

                }
            }
            .along {
                width: 37.86%;
                /*background: #fd9200;*/ /*TODO ylb 1.0版本单独购买变灰*/
                background-color: #FF8484;
                span {
                    display: block;
                    width: 100%;
                    text-align: center;
                    line-height: 1.12rem;
                    font-size: 0.32rem;
                    color: #fff;
                }
            }
            .group {

                .along();
                width: 47.46%;
                background: #e94f4f;
            }
        }

    }

    /*TODO 加入购物车*/
    .share_b {
        justify-content: space-between;
        .goback {
            display: none;
        }
        .along, .group {
            flex: 1;
        }
    }

    /*******头部***********/
    .productDetails .header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        align-content: center;
        color: #fff;
        text-align: center;
        background: @c_headerbgColor;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 999;
        border-bottom: 1px solid #efefef;
        padding: 0 0.4rem;
        .item {
            a {
                font-size: 0.32rem;
                color: #fff;

            }
        }
        .left, .right {
            width: 0.8rem;
            height: 0.8rem;
            display: flex;
            align-items: center;
        }
        .right {
            justify-content: flex-end;
        }
    }

</style>
<style lang="less" scoped>
    .productDetails .header {
        transition: all ease 0.5s;

    }

    .productDetails .header.hide {
        background-color: rgba(255, 255, 255, 0);
        border-bottom: 0;
    }

    .productDetails .header.active {
        background-color: rgba(255, 255, 255, 1);
        border-bottom: 1px solid #efefef;
    }

</style>
<style lang="less">
    .productDetails .vux-tab-wrap {
        width: 100%;
        transition: all ease 0.5s;
        opacity: 0;
    }

    .productDetails .vux-tab-wrap.active {
        opacity: 1;
    }

    .productDetails .vux-tab .vux-tab-item {
        background-size: 100% 0;
    }

    .productDetails .vux-tab .vux-tab-item.vux-tab-selected {
        border-bottom: none;
    }

    .productDetails .vux-tab-ink-bar {
        height: 0 !important;

    }
</style>
<template>
    <div class="productDetails">
        <header :style="{height: interactive.statusBarHeight.height,paddingTop:parseFloat(interactive.statusBarHeight.height) - 0.88 + 'rem'}"
                class="header" v-show="!isShare" :class="scrollTop>25?'active':'hide'">
            <div class="item left" @click="goBack">
                <div class="back_hui_icon"></div>
            </div>
            <tab :class="scrollTop >= 25 ? 'active':''" :line-width="1" v-model="tabIndex">
                <tab-item class="vux-center" :selected="demo2 === item" v-for="(item, index) in list2"
                          @click.native="tabClick(index)" :key="index">{{item}}
                </tab-item>
            </tab>
            <div class="item right " @click="sharePage">
                <div class="right_share"></div>

            </div>
        </header>
        <div v-show="isShare" class="share_alert" @click="openApp">在App打开>></div>
        <div class="details_cont infoTab main_allScroll">
            <!--主体内容 封装组件-->
            <scroller @on-scroll="onScroll" lock-x ref="scrollerEvents">
                <div>
                    <Demo ref="product" @choiceSize="choiceSize" :good="good" @update="update" :recommendCode="recommendCode" :tuijianArr="tuijianArr" @updatePromiseInfoListShow="updatePromiseInfoListShow"></Demo>
                </div>
            </scroller>
            <!-- 底部购买 -->
            <div class="footer_buy" :class="isShare ? 'share': ''" v-if="good.status == 0" v-show="!isShare">
                <div class="goback" v-show="!isShare" @click="gotoCollage" v-if="isCollage">
                    <router-link to="">
                        <div class="goods_icon" style="margin: 0.1rem auto"></div>
                        拼购
                    </router-link>
                </div>
                <div class="goback" v-show="!isShare" @click="gotoshopCart" v-else>
                    <router-link to="">
                        <div class="shop_icon" style="margin: 0.1rem auto"></div>
                        购物车
                    </router-link>
                </div>
                <div class="along" style="width: 100%;background-color: #ccc">
                    <span>商品已下架</span>
                </div>
            </div>
            <div class="footer_buy" :class="isShare ? 'share': ''" v-else-if="isCollage" v-show="!isShare">
                <div class="goback" v-show="!isShare" @click="gotoCollage">
                    <router-link to="">
                        <div class="goods_icon" style="margin: 0.1rem auto"></div>
                        拼购
                    </router-link>
                </div>
                <div class="along disabled"
                     style="display: flex;flex-direction: column;justify-content: space-between;align-items: center;padding: 0.2rem;">
                    <span style="line-height: 0.36rem;">￥{{good.minOriginalPrice}}</span>
                    <span style="line-height: 0.36rem;">单独购买</span>
                </div>
                <div class="group" @click="isShare ? openApp() : showup(1)"
                     style="display: flex;flex-direction: column;justify-content: space-between;align-items: center;padding: 0.2rem;">
                    <span style="line-height: 0.36rem;">￥{{good.minSellPrice}}</span>
                    <span style="line-height: 0.36rem;">发起拼单</span>
                </div>
            </div>
            <div class="footer_buy" :class="isShare ? 'share': ''" v-else v-show="!isShare">
                <div class="goback" v-show="!isShare" @click="gotoshopCart">
                    <router-link to="">
                        <div class="shop_icon" style="margin: 0.1rem auto"></div>
                        购物车
                    </router-link>
                </div>
                <div class="along" @click="isShare ? openApp() : showup(0)">
                    <span>加入购物车</span>
                </div>
                <div class="group" @click="isShare ? openApp() : showup(1)">
                    <span>立即购买</span>
                </div>
            </div>
            <!--点击购买弹窗-->
            <div v-transfer-dom>
                <popup v-model="show" style="background:#fff;height: 9.37rem;overflow-y: inherit"
                       :style="{bottom: interactive.statusBarHeight.tabBarHeight}">
                    <div class="popup0">
                        <div class="header_box">
                            <img v-lazy="{src:curGood.mainImage}" alt="">
                            <div class="prise">
                                <h1>￥{{curGood.sellPrice}}</h1>
                                <div class="color_model">
                                    <span>{{curGood.specificationOneVal}}</span>
                                    <span>{{curGood.specificationTwoVal}}</span>
                                    <span>{{curGood.specificationThreeVal}}</span>
                                </div>
                            </div>
                            <div class="close" @click="closedown"></div>
                        </div>
                        <div class="content_box">
                            <div class="colors" v-for="(item, index) in Specifications" v-if="item.arr">
                                <h3>{{item.title}}</h3>
                                <div class="options">
                                <span v-for="(x,i) in item.arr" :class="[item.selected == i && item.isSelected.indexOf(x) > -1 ? 'bg_red' : '']"
                                      :id="item.isSelected.indexOf(x) > -1 ? '' : 'disabled'"
                                      @click="bg_color(item,index, i, x)" :key="i">{{x}}</span>
                                </div>
                            </div>
                            <div class="colors main_c_b_s_o">
                                <group>
                                    <x-number v-model="buyNum" @on-change="buyNumChange" title="购买数量" :min="good.minimumCount" :max="good.limitCount"
                                              fillable></x-number>
                                </group>
                            </div>
                        </div>
                        <div class="footer_ok" v-show="buyMode">
                            <button :disabled=" curGood == {} || buyNum == 0"
                                    :class="curGood == {} || buyNum== 0 ?'disabled':''"
                                    v-on:click="gotoPage">确定
                            </button>
                        </div>
                        <div class="footer_ok two" v-show="!buyMode" v-if="good.status != 0">
                            <button v-on:click="addCart" :disabled="curGood == {} || buyNum == 0"
                                    :class="curGood == {} || buyNum== 0 ?'disabled':''">加入购物车
                            </button>
                            <button :disabled=" curGood == {} || buyNum == 0"
                                    :class="curGood == {} || buyNum== 0 ?'disabled':''"
                                    v-on:click="buy">立即购买
                            </button>
                        </div>
                        <div class="footer_ok two" v-show="!buyMode" v-else>
                            <button class="disabled">商品已下架</button>
                        </div>

                    </div>
                </popup>
            </div>
            <!--点击正品保证之类-->
            <div v-transfer-dom>
                <popup v-model="promiseInfoListShow" style="background:#fff;height: 9.37rem;overflow-y: inherit;padding-top: .2rem;"
                       :style="{bottom: interactive.statusBarHeight.tabBarHeight}">
                    <div v-for=" v in good.promiseInfoList" class="promiseInfoList_box">
                        <div style="margin-bottom: .1rem;"><img :src="v.promiseUrl" alt=""><span>{{v.promiseDescribe}}</span></div>
                        <p>{{v.detailDescription}}</p>
                    </div>
                </popup>
            </div>
        </div>
    </div>
</template>
<script>
    var guige = [
        {title: '颜色', arr: ['黑', 'hong', 'lan'], selected: 0},
        {title: '尺寸', arr: ['大', '中', '小'], selected: 0},
        {title: '型号', arr: ['iphone', 'iphone2', 'iphone3'], selected: 0},
    ]
    import {Previewer, XImg, TransferDom, Scroller} from 'vux'
    import Demo from './components/product_details_cont'
    import {mapActions, mapState} from 'vuex'
    import {GET_PAYGOODS} from 'store/paygoods'
    import {
        Tab,
        TabItem,
        Popup,
        Group,
        Cell,
        XButton,
        XSwitch,
        Toast,
        XAddress,
        XNumber,
        Swiper, SwiperItem
    } from 'vux'

    export default {
        name: 'share_details',
        directives: {
            TransferDom
        },
        components: {
            Demo,
            Previewer,
            XImg,
            Popup,
            Group,
            Cell,
            XSwitch,
            Toast,
            XAddress,
            XNumber,
            XButton,
            Swiper, SwiperItem,
            Scroller,
            Tab,
            TabItem,
        },
        data() {
            return {
                getBarWidth: function (index) {
                    return '100%'
                },
                tabIndex: 0,
                list2: ['商品', '评价', '详情'],
                bg_click: 0,
                show: false, //  购买商品弹窗
                mode: true,  //  true 立即买入   false  加入购物车
                buyNum: 1, //  暂定数量
                buyMode: true, // true  选择规格后“直接”买入或加入购物车   false 选择规格后“选择”买入还是加入购物车
                Specifications: [],  // TODO 暂定规格  具体根据数据
                good: {},  //  相拼详细信息
                curGood: {}, //  当前规格的产品
                isCollage: this.$route.query.type == 1 ? true : false,
                isShare: this.$route.query.sharePage == 1 ? true : false,
                scrollTop: 0,
                recommendCode: '',
                tuijianArr: [], //  为你推荐
                promiseInfoListShow: false
            }
        },
        activated: function () {
            if (this.scrollTop != 0) {
                this.$refs.scrollerEvents.reset({top: 0})
            }
            this.good = {}
            this.curGood = {}
            this.init();
        },
        deactivated: function () {
        },
        methods: {
            ...mapActions([GET_PAYGOODS]),
            init() {

                this.bg_click = 0
                this.buyMode = true
                this.getDetail();
                // this.getPromotionTemplatesDetailInfoByTemplateId()
                this.isCollage = this.$route.query.type == 1 ? true : false
                this.isShare = this.$route.query.sharePage == 1 ? true : false
                this.comJS.checkShareInitAndIsAndroid();
                this.scrollTop = 0,
                    this.tabIndex = 0;
                document.getElementsByTagName('body')[0].style.paddingBottom = this.interactive.statusBarHeight.tabBarHeight
            },
            updatePromiseInfoListShow(boolean){
              this.promiseInfoListShow = boolean
            },
            /*****************滚动显示头部*****************/
            goBack() {
                if (this.comJS.checkFormShare()) {
                    this.Interactive.activityWebDismiss();
                } else {
                    this.$router.goBack()
                }
            },
            onScroll(pos) {
                this.scrollTop = pos.top;
                let data = document.getElementsByClassName('product_pic_box')[0].offsetTop;
                let date = document.getElementsByClassName('evaluation_box')[0].offsetTop;
                if (pos.top + 100 >= date && pos.top + 100 < data) {
                    this.tabIndex = 1
                } else if (pos.top + 100 >= data) {
                    this.tabIndex = 2
                } else {
                    this.tabIndex = 0
                }
            },
            tabClick(item) {
                this.demo2 = item;
                if (item == this.tabIndex) {
                    return;
                }
                if (item == 0) {
                    this.$refs.scrollerEvents.reset({top: 25})
                }
                if (item == 1) {
                    let data = document.getElementsByClassName('evaluation_box eval')[0].offsetTop - 100;
                    this.$refs.scrollerEvents.reset({top: data})
                    this.scrollTop = data;
                }
                if (item == 2) {
                    let date = document.getElementsByClassName('product_pic_box')[0].offsetTop - 100;
                    this.$refs.scrollerEvents.reset({top: date})
                    this.scrollTop = date;
                }
            },


            /*********************END*************/



            gotoshopCart() {  //  去购物车页面
                if (this.comJS.checkFormShare()) {
                    this.Interactive.activityWebDismiss();
                } else {
                    this.$router.replace({path:'/shopCart',query:{}})
                }

            },
            gotoCollage() {
                if (this.comJS.checkFormShare()) {
                    this.Interactive.activityWebDismiss();
                } else {
                  this.$router.replace({path:'/collage',query:{}})
                }
            },
            update() {  // 点击为您推荐更换详情
                this.init()
                this.$refs.scrollerEvents.reset({top: 0})
                this.scrollTop = 0
            },
            //  获取商品详情
            getDetail() { // this.$route.query.templateId
                this.$ajax.getGoodsDetail({goodsId: this.$route.query.templateId})
                    .then(res => {
                        if (!res.body.content || res.body.content === null) {
                            this.good.status = 0
                            this.$vux.toast.text('商品不存在', 'middle')
                            return;
                        }
                        this.good = res.body.content
                        //  轮播图处理
                        var arr = []
                        this.good.productInfo.rollImages.split(',').forEach((v) => {
                            var a = {}
                            a.url = ''
                            a.img = v
                            arr.push(a)
                        })
                        this.good.rollImages = arr
                        this.good.detailImages = this.good.productInfo.detailImages
                        this.good.name = this.good.productInfo.name
                        this.recommendCode = this.good.productInfo.parentCategory
                        //  规格处理
                        var nameArr = ['specificationInfoOneName', 'specificationInfoTwoName', 'specificationInfoThreeName']
                        this.Specifications = []
                        nameArr.forEach((v, i) => {
                            var a = {}
                            a.title = res.body.content[v]
                            if(res.body.content.skuInfo.hasOwnProperty(v)){
                                a.arr = res.body.content['skuInfo'][v]
                            } else {
                                a.arr = null
                            }
                            a.selected = 0
                            a.isSelected = []
                            this.Specifications.push(a)
                        })
                    })
                    .then(() => {
                        this.curGoods(0)
                        // this.comJS.loadUmSDK.onEventWithParameters({type: 0, eventID: 'product_look_num',map: {'templateId': this.good.templateId, 'name': this.good.name}})
                        this.Interactive.customStatistics({type: 2, eventID: 'product_look_num',map: {'templateId': this.good.templateId, 'name': this.good.name, 'address': this.user.idCardArea}})
                        this.buyNum = this.good.minimumCount;
                    })
            },
            //  获取推荐列表
            getPromotionTemplatesDetailInfoByTemplateId () {
                this.$ajax.getPromotionTemplatesDetailInfoByTemplateId({templateId: this.$route.query.templateId})
                    .then(res => {
                        this.tuijianArr = res.body.content.recommendList
                    })
            },
            //  立即购买(1)  or  加入购物车(0)
            showup: function (mode) {
                this.show = true
                this.buyMode = true

                if (mode) {
                    this.mode = true
                } else {
                    this.mode = false
                }
            },
            closedown: function () {
                this.show = false;
            },
            //  点击选择规格
            choiceSize() {
                this.show = true
                this.buyMode = false
            },
            //  选择颜色尺寸等规格
            bg_color: function (item, index, i, x) {
                if (item.isSelected.indexOf(x) > -1) {
                    item.selected = i;
                    this.curGoods(index)
                    //  todo 针对特殊情况，3规格配置ui在掉一次该函数
                    this.curGoods(index)
                } else {
                    return
                }

            },

            buyNumChange(value){
                if(String(value).indexOf('.')>=0){
                    this.buyNum = parseInt(value);
                }
            },

            curGoods(type) {  //  遍历 查找到当前的产品
                this.Specifications.forEach((v) => {
                    v.isSelected = []
                })
                this.curGood = {}
                //  先便利找到
                var Marr = JSON.parse(JSON.stringify(this.Specifications))
                var nameArr = ['specificationOneVal', 'specificationTwoVal', 'specificationThreeVal']
                this.good.subTemplateInfoList.forEach((v) => {
                    //  寻找当前商品
                    if (!!Marr[0].arr && !!Marr[1].arr && !!Marr[2].arr) {   //  如果有三种规格
                        if (v.specificationOneVal == Marr[0].arr[Marr[0].selected] && v.specificationTwoVal == Marr[1].arr[Marr[1].selected] && v.specificationThreeVal == Marr[2].arr[Marr[2].selected]) {
                            this.curGood = v
                        }
                        //  寻找可点击
                        if (type === 0) {
                            this.IsCilckOne(v, 3)  //  点第一个
                        } else if (type === 1) {
                            this.IsCilckTwo(v, 3)  //  点第二个
                        } else if (type === 2) {
                            this.IsCilckThree(v, 3)  //  点第三个
                        }
                    } else if (!!Marr[0].arr && !!Marr[1].arr) {   //  如果有二种规格
                        if (type === 0) {
                            this.IsCilckOne(v, 2)  //  点第一个
                        } else if (type === 1) {
                            this.IsCilckTwo(v, 2)  //  点第二个
                        }
                        if (v.specificationOneVal == Marr[0].arr[Marr[0].selected] && v.specificationTwoVal == Marr[1].arr[Marr[1].selected]) {
                            this.curGood = v
                        }

                    } else if (!!Marr[0].arr) {    //  如果有1种规格
                        if (v.specificationOneVal == Marr[0].arr[Marr[0].selected]) {
                            this.curGood = v
                        }
                        this.IsCilckOne(v, 1)  //  3种规格
                    }
                })

                //  如果没有的处理逻辑 有共用内容  放入一个函数
                if (!this.curGood.hasOwnProperty('mainImage')) {
                    this.good.subTemplateInfoList.forEach((v, i) => {
                        if (!!Marr[0].arr && !!Marr[1].arr && !!Marr[2].arr) {
                            //  如果没找到
                            var a, b;
                            if (type === 0) {
                                a = 1;
                                b = 2;
                            } else if (type === 1) {
                                a = 0;
                                b = 2;
                            } else if (type === 2) {
                                a = 0;
                                b = 1;
                            }
                            if (Marr[type].arr[Marr[type].selected] == v[nameArr[type]]) {
                                this.curGood = v
                                this.isSelected(a, v[nameArr[a]])
                                this.isSelected(b, v[nameArr[b]])
                            }
                        } else if (!!Marr[0].arr && !!Marr[1].arr) {
                            var a;
                            if (type == 0) {
                                a = 1
                            } else {
                                a = 0
                            }
                            if (Marr[type].arr[Marr[type].selected] == v[nameArr[type]]) {
                                this.curGood = v
                                this.isSelected(a, v[nameArr[a]])
                            }
                        }
                    })
                }
                this.setCurGood()
                Marr=null
            },
            setCurGood() {
                this.curGood.templateId = this.$route.query.templateId
                this.curGood.name = this.good.productInfo.name
                this.curGood.detail = this.good.detail
                this.curGood.limitCount = this.good.limitCount // 最大可买
                this.curGood.minimumCount = this.good.minimumCount // 最大可买
                this.curGood.leastCount = this.good.leastCount
                this.curGood.type = this.good.type
            },
            IsCilckOne(v, num) {
                var Marr = this.Specifications
                //  寻找第一个不能点击
                this.Specifications[0].arr.forEach((value) => {
                    if (value == v.specificationOneVal) {
                        this.Specifications[0].isSelected.push(value)
                    }
                })
                if (num > 1) {
                    //  寻找第二个不能点击
                    this.Specifications[1].arr.forEach((value) => {
                        if (v.specificationOneVal == Marr[0].arr[Marr[0].selected] && value == v.specificationTwoVal) {
                            this.Specifications[1].isSelected.push(value)
                        }
                    })
                }
                if (num > 2) {
                    //  寻找第三个不能点击
                    this.Specifications[2].arr.forEach((value) => {
                        if (v.specificationTwoVal == Marr[1].arr[Marr[1].selected] && v.specificationOneVal == Marr[0].arr[Marr[0].selected] && value == v.specificationThreeVal) {
                            this.Specifications[2].isSelected.push(value)
                        }
                    })
                }
            },
            IsCilckTwo(v, num) {
                //  根据num  判断有几种规格
                var Marr = this.Specifications
                //  寻找第二个不能点击
                this.Specifications[1].arr.forEach((value) => {
                    if (value == v.specificationTwoVal) {
                        this.Specifications[1].isSelected.push(value)
                    }
                })
                if (num > 1) {
                    //  寻找第一个不能点击
                    this.Specifications[0].arr.forEach((value) => {
                        if (v.specificationTwoVal == Marr[1].arr[Marr[1].selected] && value == v.specificationOneVal) {
                            this.Specifications[0].isSelected.push(value)
                        }
                    })
                }
                if (num > 2) {
                    //  寻找第三个不能点击
                    this.Specifications[2].arr.forEach((value) => {
                        if (v.specificationTwoVal == Marr[1].arr[Marr[1].selected] && v.specificationOneVal == Marr[0].arr[Marr[0].selected] && value == v.specificationThreeVal) {
                            this.Specifications[2].isSelected.push(value)
                        }
                    })
                }
            },
            IsCilckThree(v, num) {
                //  根据num  判断有几种规格
                var Marr = this.Specifications
                //  寻找第三个不能点击
                this.Specifications[2].arr.forEach((value) => {
                    if (value == v.specificationThreeVal) {
                        this.Specifications[2].isSelected.push(value)
                    }
                })
                if (num > 1) {
                    //  寻找第三个不能点击
                    this.Specifications[0].arr.forEach((value) => {
                        if (v.specificationThreeVal == Marr[2].arr[Marr[2].selected] && value == v.specificationOneVal) {
                            this.Specifications[0].isSelected.push(value)
                        }
                    })
                }
                if (num > 2) {
                    //  寻找第二个不能点击
                    this.Specifications[1].arr.forEach((value) => {
                        if (v.specificationThreeVal == Marr[2].arr[Marr[2].selected] && v.specificationOneVal == Marr[0].arr[Marr[0].selected] && value == v.specificationTwoVal) {
                            this.Specifications[1].isSelected.push(value)
                        }
                    })
                }
            },
            isSelected(a, data) {  //根据规格 确定选中值
                this.Specifications[a].arr.forEach((value, index) => {
                    if (value == data) {
                        this.Specifications[a].selected = index
                    }
                })
            },
            //  规格部分函数结束
            //  点击确定
            gotoPage() {
                if (this.mode) {
                    this.buy()
                } else {
                    this.addCart()
                }
            },
            buy() {  //  立即买入
                var a = this.curGood
                a.buyNum = this.buyNum
                a.inviteCode = this.$route.query.inviteCode || null
                a.activityId = this.$route.query.activityId || null
                if(this.$route.query.activityId){
                    this.getActivityName(a)
                } else {
                    this.getAvailableActivity(a)
                }
            },
            getAvailableActivity(a){
                this.$ajax.getAvailableActivity({templateId: this.$route.query.templateId})
                    .then(res => {
                        if(res.body.content && res.body.content.length > 0){
                            var boolean = false
                            res.body.content.forEach((v) => {
                                if(v.activityId == '475252186549321728'){
                                    boolean = true
                                    this.getActivityName(a, '475252186549321728')
                                }
                            })
                        }
                        if(!boolean){
                            this.GET_PAYGOODS([a])
                            this.gotoPay()
                        }
                    })
            },
            gotoPay(){
                if(this.curGood.type == 3 || this.curGood.type == 5){
                    this.$router.push({path: '/home/subOrder', query: {type: this.curGood.type}})
                } else {
                    this.$router.push({path: '/home/collage_subOrder', query: {type: this.curGood.type}})
                }
            },
            getActivityName(data, activityId){
                this.$ajax.getActivityDetailInfo({
                    activityId: this.$route.query.activityId || activityId
                })
                    .then(res=>{
                        var obj = JSON.parse(JSON.stringify(data))
                        obj.activityId = this.$route.query.activityId || activityId
                        obj.activityName = res.body.content.activityName
                        this.GET_PAYGOODS([obj])
                        obj = null
                        this.gotoPay()
                    })
            },
            addCart() {
                if(!this.comJS.getCookie('t')){
                    this.Interactive.pushTokentoJS()
                    return;
                }
                this.$ajax.cartAdd({
                    "subTemplateId": this.curGood.subTemplateId,
                    "buyNum": this.buyNum,
                    "inviteCode": this.$route.query.inviteCode || null,
                    "activityId": this.$route.query.activityId || 0
                })
                    .then(res => {
                        this.$vux.toast.text('成功加入购物车', 'middle')
                        this.show = false
                    })
                    .catch(()=>this.show = false)
            },
            sharePage() {  // 分享当前页面
                let obj = {
                    "title": "【￥" + (this.good.minSellPrice != null ? this.good.minSellPrice : this.good.minOriginalPrice) + "】" + this.good.productInfo.name,
                    "content": '我在铺连铺发现了一个不错的商品，快来看看吧！',
                    "imageUrl": this.good.productInfo.mainImage,
                    "shareUrl": this.comJS.addSharePageUrl(window.location.href),
                    "originalPage": '/pages/goods/goodDetail?goodsId=' + this.$route.query.templateId + '&inviteCode=' + localStorage.getItem('inviteCode') + '&form=share'
                }
                this.Interactive.shareClick(obj);
            },
            openApp() {
                this.comJS.openApp()
                return
            }
        },
        computed: mapState({interactive: state => state.interactive,user: state => state.user})
    }
</script>
<style lang="less" scoped>
    .promiseInfoList_box{
        padding: 0 .3rem;
        font-size: .24rem;
        color:#333;
        line-height: 1.5;
        margin-bottom: .2rem;
        div{
            display: flex;
            justify-content: flex-start;
            align-items: center;
        }
        img{
            width: .32rem;
            display: block;
            margin-right: .1rem;
        }
    }
</style>


